cmake_minimum_required(VERSION 3.10)
project(PslDyna LANGUAGES Fortran)

# 开启 Fortran O3 优化
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -O3")
# 设置 Fortran 标准
set(CMAKE_Fortran_STANDARD 2008)
set(CMAKE_Fortran_STANDARD_REQUIRED ON)

# 设置模块输出目录
set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/mods)

# 查找 LAPACK 和 BLAS
find_package(LAPACK REQUIRED)
find_package(BLAS REQUIRED)

# # 添加可执行文件 壳单元的计算
# add_executable(pdyna
# src/pdyna.f90
#     src/bcs_mod.f90
#     src/sconstants_mod.f90
#     src/matrix_utils_mod.f90
#     src/solid_mod.f90
#     src/shell_mod.f90
#     src/writer_mod.f90
#     src/reader_mod.f90
#     src/ls_mod.f90)
    
# # 链接 LAPACK 和 BLAS
# target_link_libraries(pdyna ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
    
# 添加可执行文件 c3d8, c3d8i单元的计算
add_executable(sdyna
    src/sdyna.f90
    src/mesh_reader_mod.f90
    src/dbc_reader_mod.f90
    src/fbc_reader_mod.f90
    src/amplitude_reader_mod.f90
    src/writer_mod.f90
    src/solid_mod.f90
    src/ls_mod.f90
    src/bcs_mod.f90
    src/matrix_utils_mod.f90
    src/shell_mod.f90
    src/sconstants_mod.f90
    )

# 链接 LAPACK 和 BLAS
target_link_libraries(sdyna ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})

# 添加可执行文件 工具一: dbc_gen.exe
add_executable(dbc_gen
    tools/dbc_gen.f90
)

# 添加可执行文件 工具二: fbc_gen.exe
add_executable(fbc_gen
    tools/fbc_gen.f90
)

# 添加可执行文件 工具三: amp_gen.exe
add_executable(amp_gen
    tools/amp_gen.f90
)